cmake_minimum_required(VERSION 3.0)
project(ObjectTrace VERSION 1.0.0)

set(CMAKE_CXX_FLAGS "-static -static-libgcc -static-libstdc++ -Wall -Werror")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O2 -DTSFUNCS_DEBUG=false")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -Og")

add_definitions(-DPROJECT_NAME="${CMAKE_PROJECT_NAME}")
add_definitions(-DPROJECT_EXPORT=${CMAKE_PROJECT_NAME})
add_definitions(-DPROJECT_VERSION="${CMAKE_PROJECT_VERSION}")

set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)

include_directories("include/")

set(CMAKE_FIND_LIBRARY_PREFIXES "" "lib")
set(CMAKE_FIND_LIBRARY_SUFFIXES "" ".lib" ".a")

find_library(MINHOOK_LIB_RELEASE_LOC
	NAMES minhook libminhook minhook.x32 minhook.x64
	PATHS ${TSFUNCS_LIBRARY_DIRS}
	REQUIRED
)

find_library(MINHOOK_LIB_DEBUG_LOC
	NAMES minhookd libminhookd minhook.x32d minhook.x64d
	PATHS ${TSFUNCS_LIBRARY_DIRS}
	REQUIRED
)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
	set(MINHOOK_LIB_LOC ${MINHOOK_LIB_DEBUG_LOC})
else ()
	set(MINHOOK_LIB_LOC ${MINHOOK_LIB_RELEASE_LOC})
endif ()

add_library(minhook STATIC IMPORTED)
set_target_properties(minhook PROPERTIES IMPORTED_LOCATION "${MINHOOK_LIB_LOC}")

add_library(${CMAKE_PROJECT_NAME} SHARED
	src/main.cpp
)

set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")

target_link_libraries(${CMAKE_PROJECT_NAME}
	minhook
	psapi
)

set(EXECUTABLE_OUTPUT_PATH ${dir}release)
set(LIBRARY_OUTPUT_PATH ${dir}release)

